def parseCommandLine(argv):
- opts = gopts
- args = opts.parse(argv)
- if opts.vals.help:
- opts.usage()
- if opts.vals.help or opts.vals.help_config:
- opts.load_defconfig(help=1)
- if opts.vals.help or opts.vals.help_config:
+ gopts.reset()
+ args = gopts.parse(argv)
+ if gopts.vals.help:
+ gopts.usage()
+ if gopts.vals.help or gopts.vals.help_config:
+ gopts.load_defconfig(help=1)
+ if gopts.vals.help or gopts.vals.help_config:
return (None, None)
- if not opts.vals.display:
- opts.vals.display = os.getenv("DISPLAY")
+ if not gopts.vals.display:
+ gopts.vals.display = os.getenv("DISPLAY")
# Process remaining args as config variables.
for arg in args:
if '=' in arg:
(var, val) = arg.strip().split('=', 1)
gopts.setvar(var.strip(), val.strip())
- if opts.vals.config:
- config = opts.vals.config
+ if gopts.vals.config:
+ config = gopts.vals.config
else:
- opts.load_defconfig()
- preprocess(opts.vals)
- if not opts.getopt('name') and opts.getopt('defconfig'):
- opts.setopt('name', os.path.basename(opts.getopt('defconfig')))
- config = make_config(opts.vals)
+ gopts.load_defconfig()
+ preprocess(gopts.vals)
+ if not gopts.getopt('name') and gopts.getopt('defconfig'):
+ gopts.setopt('name', os.path.basename(gopts.getopt('defconfig')))
+ config = make_config(gopts.vals)
- return (opts, config)
+ return (gopts, config)
def main(argv):
self.value = None
self.set(default)
+
+ def reset(self):
+ self.specified_opt = None
+ self.specified_val = None
+ self.value = None
+ self.set(self.default)
+
+
def __repr__(self):
return self.name + '=' + str(self.specified_val)
# Option to use for bare words.
self.default_opt = None
+
+ def reset(self):
+ self.vals = OptVals()
+ self.vars = {}
+ for opt in self.options:
+ opt.reset()
+
+
def __repr__(self):
return '\n'.join(map(str, self.options))
are used to set options with the same names.
Variables are not used to set options that are already specified.
"""
- # Create global and lobal dicts for the file.
+ # Create global and local dicts for the file.
# Initialize locals to the vars.
# Use exec to do the standard imports and
# define variables we are passing to the script.
- globals = {}
- locals = {}
- locals.update(self.vars)
+ globs = {}
+ locs = {}
+ locs.update(self.vars)
cmd = '\n'.join(self.imports +
[ "from xen.xm.help import Vars",
"xm_file = '%s'" % defconfig,
"xm_help = %d" % help,
"xm_vars = Vars(xm_file, xm_help, locals())"
])
- exec cmd in globals, locals
+ exec cmd in globs, locs
try:
- execfile(defconfig, globals, locals)
+ execfile(defconfig, globs, locs)
except:
if not help: raise
if help:
types.IntType,
types.FloatType
]
- for (k, v) in locals.items():
+ for (k, v) in locs.items():
if self.specified(k): continue
if not(type(v) in vtypes): continue
self.setopt(k, v)